From d99a3524fd2649f1a9ce3623333de56a99e06971 Mon Sep 17 00:00:00 2001
From: secondl1ght <85003930+secondl1ght@users.noreply.github.com>
Date: Tue, 2 Aug 2022 13:23:59 -0600
Subject: lots of updates, implementing design, refactoring, bug fixes and more
---
src/routes/[username]/dashboard.svelte | 67 +++++++++++++++++++++++++++++++++-
src/routes/[username]/index.svelte | 34 +++++------------
src/routes/[username]/receive.svelte | 22 +++--------
src/routes/[username]/support.svelte | 45 +++++++++++++++++++++++
4 files changed, 125 insertions(+), 43 deletions(-)
create mode 100644 src/routes/[username]/support.svelte
(limited to 'src/routes/[username]')
diff --git a/src/routes/[username]/dashboard.svelte b/src/routes/[username]/dashboard.svelte
index 1935b156..4c0e4cfc 100644
--- a/src/routes/[username]/dashboard.svelte
+++ b/src/routes/[username]/dashboard.svelte
@@ -1,5 +1,70 @@
-
+{#if $user}
+
+
+
+
{$user.username}
+ Address goes here
+
+
+
+
+
Dashboard
+
+
Bitcoin Price: {$rate ? btcPrice : 'fetching rate...'}
+ {$preferredCurrency}
+
+
+
Data from Binance.
+
+
+
+ ACCOUNT BALANCE
+
+
+
{$rate ? accountBalanceFiat : 'fetching rate...'}
+
+
{accountBalanceBtc} BTC ({accountBalanceSats} SATS)
+
+
+
+
+ You will be charged a 1% withdrawal fee ({$rate ? feeAmount : 'fetching rate...'}) on your balance.
+
+
+
+{/if}
diff --git a/src/routes/[username]/index.svelte b/src/routes/[username]/index.svelte
index 6002efdc..41d60849 100644
--- a/src/routes/[username]/index.svelte
+++ b/src/routes/[username]/index.svelte
@@ -1,5 +1,4 @@
{#if username}
@@ -57,33 +44,30 @@
Address goes here
-
+ -->
+ class="w-[292px] md:w-[342px] h-[342px] border border-lightgrey rounded-3xl flex p-5 justify-center items-center relative"
+ />
-
Scan to pay with Bitcoin
+
Scan to pay with bitcoin
{lightningAddress}
-
diff --git a/src/routes/[username]/receive.svelte b/src/routes/[username]/receive.svelte
index 50fddbed..f0fa0fbd 100644
--- a/src/routes/[username]/receive.svelte
+++ b/src/routes/[username]/receive.svelte
@@ -3,13 +3,12 @@
import { AppHeader, Icon } from '$comp';
import { goto } from '$app/navigation';
import { invoiceAmount, invoiceAmountFiat, rate, user } from '$lib/store';
- import { post } from '$lib/utils';
+ import { post, warning } from '$lib/utils';
import { page } from '$app/stores';
let useFiat = true;
let amountFiat = 0;
let amountSats = 0;
- let message = '';
$: amount = useFiat ? Math.round(amountFiat / ($rate / 100000000)) : amountSats;
@@ -33,9 +32,6 @@
const numPad = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '0', '<'];
const handleInput = (value) => {
- if (message) {
- message = '';
- }
if (useFiat) {
if (amountFiat === 0 && value !== '.' && value !== '<' && value !== '0') {
amountFiat = value;
@@ -54,7 +50,7 @@
}
}
} else if (value !== '.' && value !== '<' && parseInt(amountFiat + value) > $rate) {
- message = 'Please enter an amount less than 1 bitcoin.';
+ warning('Please enter an amount less than 1 bitcoin.');
} else if (amountFiat !== 0 && amountFiat.match(/\.../)) {
return;
} else {
@@ -74,7 +70,7 @@
}
}
} else if (value !== '<' && parseInt(amountSats + value) > 100000000) {
- message = 'Please enter an amount less than 1 bitcoin.';
+ warning('Please enter an amount less than 1 bitcoin.');
} else {
amountSats = amountSats + value;
}
@@ -118,16 +114,6 @@
>
-
- {#if message}
-
- {/if}
-
{#each numPad as value}
@@ -172,10 +158,12 @@
on:click={submit}
disabled={$invoiceAmount === 0}> Show QR
+
{:else}
diff --git a/src/routes/[username]/support.svelte b/src/routes/[username]/support.svelte
new file mode 100644
index 00000000..7dd254c1
--- /dev/null
+++ b/src/routes/[username]/support.svelte
@@ -0,0 +1,45 @@
+
+
+{#if $user}
+
+
+
+{/if}
--
cgit v1.2.3
From a421da7ca5e67972d833e36c5bd1cbf6bb76a477 Mon Sep 17 00:00:00 2001
From: secondl1ght <85003930+secondl1ght@users.noreply.github.com>
Date: Tue, 2 Aug 2022 14:33:58 -0600
Subject: add transactions page
---
src/routes/[username]/dashboard.svelte | 2 +-
src/routes/[username]/support.svelte | 2 +-
src/routes/[username]/transactions.svelte | 48 ++++++++++++++++++++++++++++++-
3 files changed, 49 insertions(+), 3 deletions(-)
(limited to 'src/routes/[username]')
diff --git a/src/routes/[username]/dashboard.svelte b/src/routes/[username]/dashboard.svelte
index 4c0e4cfc..6f38a812 100644
--- a/src/routes/[username]/dashboard.svelte
+++ b/src/routes/[username]/dashboard.svelte
@@ -36,7 +36,7 @@
-
Dashboard
+
Dashboard
Bitcoin Price: {$rate ? btcPrice : 'fetching rate...'}
diff --git a/src/routes/[username]/support.svelte b/src/routes/[username]/support.svelte
index 7dd254c1..f974bd80 100644
--- a/src/routes/[username]/support.svelte
+++ b/src/routes/[username]/support.svelte
@@ -8,7 +8,7 @@
-
Support
+
Support
diff --git a/src/routes/[username]/settings.svelte b/src/routes/[username]/settings.svelte
index ae8e91c1..82ed7305 100644
--- a/src/routes/[username]/settings.svelte
+++ b/src/routes/[username]/settings.svelte
@@ -71,6 +71,15 @@
+
+
+
+
+
Email Notifications
diff --git a/src/routes/[username]/transactions.svelte b/src/routes/[username]/transactions.svelte
index 0e635298..24e3e146 100644
--- a/src/routes/[username]/transactions.svelte
+++ b/src/routes/[username]/transactions.svelte
@@ -16,30 +16,35 @@
-
+
AMOUNT
- TIME
+ TYPE
+ TIME
{#if transactions.length}
{#each transactions as tx}
-
+
{new Intl.NumberFormat('en-US', {
+ >{tx.amount > 0 && '+'}{new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
}).format(tx.amount * (tx.rate / 100000000))}
({new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }).format(tx.amount)}
- SATS)
+ >{new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }).format(tx.amount)}
+ SATS
-
+
+ {tx.amount < 0 ? 'Sent' : 'Received'}
+
+
+
{new Date(tx.createdAt).toLocaleDateString(undefined, { dateStyle: 'medium' })}
--
cgit v1.2.3
From dcd4fe70f6f23a5ac2df3b773fea89c1acd878b6 Mon Sep 17 00:00:00 2001
From: Adam Soltys
Date: Fri, 5 Aug 2022 10:21:48 -0700
Subject: lightning withdrawals
---
src/lib/socket.js | 8 +++++-
src/lib/utils.js | 8 +++---
src/routes/[username]/dashboard.svelte | 49 ++++++++++++++++++++++++++++------
src/routes/withdraw.js | 10 +++++++
4 files changed, 63 insertions(+), 12 deletions(-)
create mode 100644 src/routes/withdraw.js
(limited to 'src/routes/[username]')
diff --git a/src/lib/socket.js b/src/lib/socket.js
index c1b68a12..a30d4376 100644
--- a/src/lib/socket.js
+++ b/src/lib/socket.js
@@ -1,5 +1,6 @@
import { get } from 'svelte/store';
import { rate, user, token, invoices, preferredCurrency, newPayment } from '$lib/store';
+import { success } from '$lib/utils';
let interval, socket;
@@ -18,8 +19,13 @@ export const messages = (data) => ({
},
payment() {
- invoices.set({ ...get(invoices), [data.invoice.uuid]: data.invoice });
+ if (data.invoice) invoices.set({ ...get(invoices), [data.invoice.uuid]: data.invoice });
newPayment.set(true);
+ if (data.amount > 0) {
+ success(`Received ${data.amount} sats!`);
+ } else {
+ success(`Sent ${-data.amount} sats!`);
+ }
},
connected: auth,
diff --git a/src/lib/utils.js b/src/lib/utils.js
index a812c136..24f94d40 100644
--- a/src/lib/utils.js
+++ b/src/lib/utils.js
@@ -18,11 +18,12 @@ export const get = (url, headers = { accept: 'application/json' }) =>
}
});
-export const post = (url, body) =>
- fetch(base + url, {
+export const post = (url, body, headers) => {
+ headers = { ...headers, accept: 'application/json', 'content-type': 'application/json' };
+ return fetch(base + url, {
method: 'POST',
body: JSON.stringify(body),
- headers: { accept: 'application/json', 'content-type': 'application/json' }
+ headers
})
.then((r) => r.text())
.then((body) => {
@@ -37,6 +38,7 @@ export const post = (url, body) =>
return body;
});
+}
export const copy = (text) => {
navigator.clipboard.writeText(text);
diff --git a/src/routes/[username]/dashboard.svelte b/src/routes/[username]/dashboard.svelte
index 11295728..7fab2125 100644
--- a/src/routes/[username]/dashboard.svelte
+++ b/src/routes/[username]/dashboard.svelte
@@ -1,7 +1,29 @@
{#if $user}
@@ -13,7 +15,13 @@
{/if}
diff --git a/src/routes/[username]/transactions.svelte b/src/routes/[username]/transactions.svelte
index 24e3e146..c91fd900 100644
--- a/src/routes/[username]/transactions.svelte
+++ b/src/routes/[username]/transactions.svelte
@@ -18,8 +18,8 @@
AMOUNT
- TYPE
- TIME
+ TYPE
+ TIME
@@ -28,19 +28,21 @@
{tx.amount > 0 && '+'}{new Intl.NumberFormat('en-US', {
+ >{tx.amount > 0 ? '+' : ''}{new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
}).format(tx.amount * (tx.rate / 100000000))}
{new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }).format(tx.amount)}
+ >{tx.amount > 0 ? '+' : ''}{new Intl.NumberFormat('en-US', {
+ maximumFractionDigits: 0
+ }).format(tx.amount)}
SATS
-
+
{tx.amount < 0 ? 'Sent' : 'Received'}
diff --git a/src/routes/withdraw.js b/src/routes/withdraw.js
index aaed2250..818d39da 100644
--- a/src/routes/withdraw.js
+++ b/src/routes/withdraw.js
@@ -1,8 +1,7 @@
import { post } from '$lib/utils';
export async function POST({ locals, request }) {
let { token } = locals;
- let body = await request.json();
- console.log(body)
+ let body = await request.json();
body = await post('/lightning/send', body, {
authorization: `Bearer ${token}`
});
--
cgit v1.2.3